<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('更新HBase表属性信息')"/>
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-table-edit" th:object="${tableDescDto}">
        <input name="tableId" th:field="*{tableId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">表名:</label>
            <div class="col-sm-8">
                <input name="tableName" th:field="*{tableName}" class="form-control" type="text" disabled>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">标签:</label>
            <div class="col-sm-8">
                <select id="hbaseTag" class="form-control select2-multiple" multiple>
                    <option th:each="tag:${tags}" th:value="${tag.tagId}" th:text="${tag.tagName}" th:selected="${tag.flag}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">是否禁用：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_hbase_table_disable')}">
                    <input type="radio" th:id="${dict.dictCode}" name="disableFlag" th:value="${dict.dictValue}"
                           th:field="*{disableFlag}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">状态:</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_hbase_table_status')}">
                    <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}"
                           th:field="*{status}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注:</label>
            <div class="col-sm-8">
                <textarea name="remark" th:field="*{remark}"  maxlength="500" placeholder="在这里填写你的其他需求......" class="form-control" rows="5"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js" />

<script th:inline="javascript">
    var prefix = ctx + "system/table";
    $("#form-table-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-table-edit").serializeArray();
            var tagIds = $.form.selectSelects("hbaseTag");
            data.push({"name": "tagIds", "value": tagIds});

            $.operate.save(prefix + "/edit", data);
        }
    }

    $(function() {
        $('#hbaseTag').select2({
            placeholder: "请选择表标签",
            allowClear: true
        });
    })
</script>
</body>
</html>